/**
 * Created by Administrator on 2017/3/21.
 */
import React, { Component, Fragment } from 'react';
import { Form, Input, DatePicker, Select, InputNumber,  Button } from 'antd';
import {connect} from 'dva';
import request from '@/utils/request';
import ReactDataGrid from 'react-data-grid';
import party from '../../images/party.png';
import gold from '../../images/gold.png';
import sortBy from 'lodash/sortBy'
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      data:[]
    };
  }
  componentDidMount() {
    const that=this;
    request(`/all_party_member_comments`, {
      method: 'GET',
      params:{
        party_member_id:this.props.party_member_id,
        order_direction:'desc',
        order_column:'yaer'
      }
    }).then((response)=> {
      if(response.status===200){
        let data=[]
        that.setState({
          data:response.data.data
        })

      }
    })

  }
  render() {
    console.log('this.state.data',this.state.data)
    const reverceData=this.state.data
    const {getFieldDecorator} = this.props.form;
    const defaultColumnProperties = {
      resizable: true,
    };
    const columns = [
      {
        name: '评议所属年份',
        width: 120,
        key: 'year',
      },
      {
        name: '评议等级',
        width: 100,
        key: 'rating',
        formatter: (event) => {
          if(event.value===1){
            return <p className="table-status table-success">优秀</p>
          }else if(event.value===2){
            return <p className="table-status table-warm">合格</p>
          }else if(event.value===3){
            return <p className="table-status table-warm">基本合格</p>
          }else if(event.value===4){
            return <p className="table-status table-error">不合格</p>
          }else{
            return ''
          }
        },
      },
      {
        name: '评价时间',
        width: 160,
        key: 'created_at',
      },
      {
        name: '备注',
        width: 170,
        key: 'remark',
      },

    ].map(c => ({  ...defaultColumnProperties,...c }));
    return (
      <div>
        <ReactDataGrid
          columns={columns}
          rowGetter={i => reverceData[i]}
          rowsCount={reverceData.length}
          minHeight={'88vh'}
        />
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);
